
/**
 * AppleIIGo
 * Slot Device class
 * (C) 2007-2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include <string.h>

#include "SlotDevice.h"

#include "InternalLanguageCard.h"
#include "InternalROM.h"
#include "InternalACIA.h"
#include "InternalMemoryExpansion.h"
#include "LanguageCard.h"
#include "SaturnRAMBoard.h"
#include "AppleIIMemoryExpansionCard.h"
#include "SuperSerialCard.h"
#include "SilentypeInterfaceCard.h"
#include "Videoterm.h"
#include "AppleClock.h"
#include "ThunderclockPlus.h"
#include "TimeMasterIIHO.h"
#include "GraphicsTabletInterfaceCard.h"
#include "MouseInterfaceCard.h"
#include "DigiSector65.h"
#include "GrapplerPlus.h"

#include "DiskII13SectorInterfaceCard.h"
#include "DiskII16SectorInterfaceCard.h"
#include "InternalIWM.h"
#include "InternalSmartPortIWM.h"
#include "InternalSmartPort2IWM.h"
#include "Apple35FloppyDiskDriveInterfaceCard.h"

class SlotDevice * SlotDevice::getInstance(char * slotDeviceType,
										   Motherboard * motherboard,
										   char * slotDeviceName) {
	if (!strcmp(slotDeviceType, "InternalLanguageCard"))
		return new InternalLanguageCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "InternalROM"))
		return new InternalROM(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "InternalACIA"))
		return new InternalACIA(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "InternalMemoryExpansion"))
		return new InternalMemoryExpansion(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "LanguageCard"))
		return new LanguageCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "SaturnRAMBoard"))
		return new SaturnRAMBoard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "AppleIIMemoryExpansionCard"))
		return new AppleIIMemoryExpansionCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "SuperSerialCard"))
		return new SuperSerialCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "SilentypeInterfaceCard"))
		return new SilentypeInterfaceCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "Videoterm"))
		return new Videoterm(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "AppleClock"))
		return new AppleClock(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "ThunderclockPlus"))
		return new ThunderclockPlus(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "TimeMasterIIHO"))
		return new TimeMasterIIHO(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "GraphicsTabletInterfaceCard"))
		return new GraphicsTabletInterfaceCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "MouseInterfaceCard"))
		return new MouseInterfaceCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "DigiSector65"))
		return new DigiSector65(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "GrapplerPlus"))
		return new GrapplerPlus(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "DiskII13SectorInterfaceCard"))
		return new DiskII13SectorInterfaceCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "DiskII16SectorInterfaceCard"))
		return new DiskII16SectorInterfaceCard(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "InternalIWM"))
		return new InternalIWM(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "InternalSmartPortIWM"))
		return new InternalSmartPortIWM(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "InternalSmartPort2IWM"))
		return new InternalSmartPort2IWM(motherboard, slotDeviceName);
	else if (!strcmp(slotDeviceType, "Apple35FloppyDiskDriveInterfaceCard"))
		return new Apple35FloppyDiskDriveInterfaceCard(motherboard,
													   slotDeviceName);
	else
		return new SlotDevice(motherboard, slotDeviceName);
}

SlotDevice::SlotDevice(Motherboard * motherboard,
					   char * slotDeviceName) :
Device(motherboard, slotDeviceName) {
}

void SlotDevice::onDevicesConnected() {
	timingGenerator = motherboard->getTimingGenerator();
}

void SlotDevice::writeIo(UINT16 address, UINT8 value) {
}

UINT8 SlotDevice::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

void SlotDevice::writeMemory(UINT16 address, UINT8 value) {
}

UINT8 SlotDevice::readMemory(UINT16 address) {
	return timingGenerator->readFloatingBus();
}
